﻿/* File Created: сентября 11, 2012 */
var uploadManager = null;
function UploadManager() {
    var $this = this;
    $this.uploadURI = "";

    $this.uploadPhoto = function (imageURI) {
        var options = new FileUploadOptions();
        options.fileKey = "file";
        options.fileName = imageURI.substr(imageURI.lastIndexOf('/') + 1);
        options.mimeType = "image/jpeg";

        var ft = new FileTransfer();
        ft.upload(imageURI, $this.uploadURI, success, fail, options);
    }

    function success(r) {
        console.log("Code = " + r.responseCode);
        console.log("Response = " + r.response);
        console.log("Sent = " + r.bytesSent);
    }

    function fail(error) {
        alert("An error has occurred: Code = " = error.code);
        console.log("upload error source " + error.source);
        console.log("upload error target " + error.target);
    }
}